﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class RTOverlay : MonoBehaviour
{
    public RenderTexture rt;
    public Camera targetCamera;
    // Use this for initialization
    void Start()
    {
        rt = new RenderTexture(Screen.width, Screen.height, 16, RenderTextureFormat.ARGB32);
        rt.anisoLevel = 9;
        targetCamera.targetTexture = rt;
    }
    private void OnPreCull()
    {
        if (Screen.width != rt.width || Screen.height != rt.height) Start();
    }
    public Shader shader;
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        var mat = new Material(shader);
        mat.hideFlags = HideFlags.DontSave;
        Graphics.Blit(rt, destination, mat);
    }
}
